import {request} from "@umijs/max";
import {PageParam} from "@/services/common";
import {covertTableData} from "@/utils/tableUtil";

export interface MpInfoVO {
        /**
        * id
        */
        id: string;
        /**
        * token
        */
        token: string;
        /**
        * aes_key
        */
        aesKey: string;
        /**
        * 租户id
        */
        tenantId: string;
}

export interface MpInfoQueryDTO extends PageParam {
        /**
        * id
        */
        id: string;
        /**
        * token
        */
        token: string;
        /**
        * aes_key
        */
        aesKey: string;
        /**
        * 租户id
        */
        tenantId: string;
}
export interface MpInfoUpdateDTO {
        /**
        * id
        */
        id?: string;
        /**
        * token
        */
        token?: string;
        /**
        * aes_key
        */
        aesKey?: string;
        /**
        * 租户id
        */
        tenantId?: string;
}

export const getMpInfoById = async (id: string) => {
    return request<MpInfoVO>(`/api/mpInfo?id=${id}`, {method: 'GET'})
}

export const getMpInfoList = async (params: MpInfoQueryDTO) => {
    return request<Array<MpInfoVO>>(`/api/mpInfo/list`, {method: 'GET', params})
}

export const getMpInfoPage = async (params: MpInfoQueryDTO) => {
    let response = await request<Array<MpInfoVO>>(`/api/mpInfo/page`, {method: 'GET', params})
    return covertTableData(response)
}

export const updateMpInfo = async (mpInfoUpdateDTO: MpInfoUpdateDTO) => {
    return request<MpInfoVO>(`/api/mpInfo/update`, {method: 'POST', data: mpInfoUpdateDTO})
}

export const saveMpInfo = async (mpInfoUpdateDTO: MpInfoUpdateDTO) => {
    return request<MpInfoVO>(`/api/mpInfo/save`, {method: 'POST', data: mpInfoUpdateDTO})
}

export const removeMpInfo = async (id: string) => {
    return request<boolean>(`/api/mpInfo/remove?id=${id}`, {method: 'POST'})
}
